package com.cy.demo.utils;

import java.io.Serializable;

//数据响应的结果对象
public class jsonResult<E> implements Serializable {

    /*响应的数据的**/
    private E data;
    /*状态码
    如：
    1.登录成功
    2.用户名不存在
    3.用户名正确，密码错误
    4.产生其他异常
    */
    private Integer state;
    /*状态描述信息 */
    private String message;

    public jsonResult() {
    }

    public jsonResult(E data, Integer state) {
        this.data = data;
        this.state = state;
    }

    public jsonResult(E data) {
        this.data = data;
    }

    public jsonResult(Integer state) {
        this.state = state;
    }

    public jsonResult(String message) {
        this.message = message;
    }

    public jsonResult(E data, Integer state, String message) {
        this.data = data;
        this.state = state;
        this.message = message;
    }

    public jsonResult(Throwable e) {
        this.message = e.getMessage();
    }

    public Object getData() {
        return data;
    }

    public void setData(E data) {
        this.data = data;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
